package cn.yulr.system.resource;

/**
 * 设置 系统 资源信息
 * <p>
 * 此部分主要是针对 HTTP too many open file 的问题而做出的修改
 * 主要问题是 NOFILE 的数值太小
 * <p>
 * 先获取最大值，然后将当前值设置为 最大值
 */
public class SystemResource {

    public static final int RLIMIT_RSS = 5;
    public static final int RLIMIT_NPROC = 6;
    public static final int RLIMIT_NOFILE = 7;
    public static final int RLIMIT_MEMLOCK = 8;

    static {
        System.loadLibrary("system_resource");
    }

    private static final SystemResource ourInstance = new SystemResource();

    public static SystemResource getInstance() {
        return ourInstance;
    }

    private SystemResource() {
    }

    public native void setrlimit(int resource, int limit_cur, int limit_max);

    public native int getrlimit_cur(int resource);

    public native int getrlimit_max(int resource);

}
